]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
messageTray: Primarily use a GIcon to drive the source's icon
authorJasper St. Pierre <jstpierre@mecheye.net>
Sat, 15 Sep 2012 06:10:15 +0000 (03:10 -0300)
committerJasper St. Pierre <jstpierre@mecheye.net>
Tue, 16 Oct 2012 16:14:16 +0000 (12:14 -0400)
This is a bit of a cleanup since we ported notification icons/secondary
icons to be in the same situation.

https://bugzilla.gnome.org/show_bug.cgi?id=680426

js/ui/components/autorunManager.js
js/ui/components/telepathyClient.js
js/ui/messageTray.js

index 83ca89448bab540046495a7753e6d51aff1ef736..bf94759709f2d8f56c97311043edfeb5f6d337c9 100644 (file)
@@ -546,9 +546,8 @@ const AutorunTransientSource = new Lang.Class({
         this.notify(this._notification);
     },
 
-    createIcon: function(size) {
-        return new St.Icon({ gicon: this.mount.get_icon(),
-                             icon_size: size });
+    getIcon: function() {
+        return this.mount.get_icon();
     }
 });
 
index 26e19edf282a3d79e09d805aa35631b6522796bb..062c9304d152891d70b080c714388ff56b306090 100644 (file)
@@ -509,24 +509,16 @@ const ChatSource = new Lang.Class({
         this._notification.appendAliasChange(oldAlias, newAlias);
     },
 
-    createIcon: function(size) {
-        this._iconBox = new St.Bin({ style_class: 'avatar-box' });
-        this._iconBox._size = size;
-        let textureCache = St.TextureCache.get_default();
+    getIcon: function() {
         let file = this._contact.get_avatar_file();
-
         if (file) {
-            let uri = file.get_uri();
-            this._iconBox.child = textureCache.load_uri_async(uri, this._iconBox._size, this._iconBox._size);
+            return new Gio.FileIcon({ file: file });
         } else {
-            this._iconBox.child = new St.Icon({ icon_name: 'avatar-default',
-                                                icon_size: this._iconBox._size });
+            return new Gio.ThemedIcon({ name: 'avatar-default' });
         }
-
-        return this._iconBox;
     },
 
-    createSecondaryIcon: function() {
+    getSecondaryIcon: function() {
         let iconName;
         let presenceType = this._contact.get_presence_type();
 
@@ -732,7 +724,7 @@ const ChatSource = new Lang.Class({
 
         title = GLib.markup_escape_text(this.title, -1);
 
-        this._notification.update(this._notification.title, null, { customContent: true, secondaryGIcon: this.createSecondaryIcon() });
+        this._notification.update(this._notification.title, null, { customContent: true, secondaryGIcon: this.getSecondaryIcon() });
 
         if (message)
             msg += ' <i>(' + GLib.markup_escape_text(message, -1) + ')</i>';
@@ -760,7 +752,7 @@ const ChatNotification = new Lang.Class({
     Extends: MessageTray.Notification,
 
     _init: function(source) {
-        this.parent(source, source.title, null, { customContent: true, secondaryGIcon: source.createSecondaryIcon() });
+        this.parent(source, source.title, null, { customContent: true, secondaryGIcon: source.getSecondaryIcon() });
         this.setResident(true);
 
         this._responseEntry = new St.Entry({ style_class: 'chat-response',
@@ -1070,9 +1062,8 @@ const ApproverSource = new Lang.Class({
         this.parent();
     },
 
-    createIcon: function(size) {
-        return new St.Icon({ gicon: this._gicon,
-                             icon_size: size });
+    getIcon: function() {
+        return this._gicon;
     }
 });
 
index c41b492f92dcc32ef5f3d634a506ebadcc114991..cd5fd26551b301981c53e816837548b515da37a3 100644 (file)
@@ -1122,10 +1122,14 @@ const Source = new Lang.Class({
     // Provides a sane default implementation, override if you need
     // something more fancy.
     createIcon: function(size) {
-        return new St.Icon({ icon_name: this.iconName,
+        return new St.Icon({ gicon: this.getIcon(),
                              icon_size: size });
     },
 
+    getIcon: function() {
+        return new Gio.ThemedIcon({ name: this.iconName });
+    },
+
     _ensureMainIcon: function() {
         if (this._mainIcon)
             return;